﻿using Autofac.Extras.DynamicProxy;
using WebAPI测试程序.AOP;
using WebAPI测试程序.Attr;
using WebAPI测试程序.IServices;

namespace WebAPI测试程序.Services
{
    [Intercept(typeof(CustomInterceptor))]
    public class UserService : IUserService
    {
        //[Autowire]
        //public ILogger<UserService> logger { get; set; }

        //[Autowire]
        //public IOrderService orderService { get; set; }

        private readonly ILogger<UserService> logger;
        private readonly IOrderService orderService;

        public UserService(ILogger<UserService> logger, IOrderService orderService)
        {
            this.logger = logger;
            this.orderService = orderService;
        }

        public void Debug()
        {
            logger.LogDebug("这是调试信息");
        }

        public void DosomeThing()
        {
            Console.WriteLine("Begin doSomething");
        }

        public void Error()
        {
            logger.LogError("这是错误信息");
        }

        public void Info()
        {
            logger.LogInformation("这是日志信息");
        }

        public void Warn()
        {
            logger.LogWarning("这是警告信息");
        }

        public virtual void Login()
        {
            Console.WriteLine("用户登录完成");
            orderService.Order();
        }
    }
}


